package com.fwzc.giuseppe.activity;

import java.util.ArrayList;
import java.util.HashMap;

import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ListView;

import com.fwzc.giuseppe.R;
import com.fwzc.giuseppe.adapter.ShopCartAdapter;
import com.fwzc.giuseppe.base.BaseActivity;

public class ShopCartActivity extends BaseActivity implements OnClickListener {
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.shopping_cart);
		initBar();
		actionbar_side_name.setText("购物车");
		bg_actionbar_side.setBackgroundColor(getResources().getColor(R.color.transparent));
		iv_actionbar_side_left.setVisibility(View.VISIBLE);
		iv_actionbar_side_left.setOnClickListener(this);
//		tv_actionbar_side_right.setVisibility(View.VISIBLE);
//		tv_actionbar_side_right.setText("删除");
//		tv_actionbar_side_right.setOnClickListener(this);

		initView();
		}


	private void initView() {
		// TODO Auto-generated method stub
		ListView listView = (ListView) findViewById(R.id.shop_listview);
		// 生成动态数组
		ArrayList<HashMap<String, Object>> listitem = new ArrayList<HashMap<String, Object>>();
		for (int i = 0; i < 10; i++) {
			HashMap<String, Object> map = new HashMap<String, Object>();
			map.put("itemimage", R.drawable.shoes1); // 图像资源的ID
			map.put("itemtitle", "名字" + i);
			map.put("itemZipcode", "0000" + i);
			map.put("price", "￥5");
			map.put("number", i);
			listitem.add(map);
			
			// 调用lvButtonAdapter方法，用来放置item中的元素
			ShopCartAdapter listItemAdapter = new ShopCartAdapter(this, listitem,
					R.layout.activity_listview, new String[] { "itemimage",
							"itemtitle", "price", "btadd", "btcut", "number",
							"itemZipcode" }, new int[] { R.id.itemimage,
							R.id.itemtitle, R.id.price, R.id.itemadd, R.id.itemcut,
							R.id.number, R.id.itemZipcode });
			listView.setAdapter(listItemAdapter);
		}
	}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		switch (v.getId()) {
		// 返回
		case R.id.iv_actionbar_side_left:
			finish();
			break;

		default:
			break;
		}
	}
}